var app = {};
let option;

const posList = [
  'left',
  'right',
  'top',
  'bottom',
  'inside',
  'insideTop',
  'insideLeft',
  'insideRight',
  'insideBottom',
  'insideTopLeft',
  'insideTopRight',
  'insideBottomLeft',
  'insideBottomRight'
];
app.configParameters = {
  rotate: {
    min: -90,
    max: 90
  },
  align: {
    options: {
      left: 'left',
      center: 'center',
      right: 'right'
    }
  },
  verticalAlign: {
    options: {
      top: 'top',
      middle: 'middle',
      bottom: 'bottom'
    }
  },
  position: {
    options: posList.reduce(function(map, pos) {
      map[pos] = pos;
      return map;
    }, {})
  },
  distance: {
    min: 0,
    max: 100
  }
};
app.config = {
  // rotate: 90,
  align: 'left',
  fontSize: 10,
  verticalAlign: 'middle',
  position: 'insideBottom',
  distance: 15,
  onChange: function() {
    const labelOption = {
      rotate: app.config.rotate,
      align: app.config.align,
      verticalAlign: app.config.verticalAlign,
      position: app.config.position,
      distance: app.config.distance
    };
    myChart.setOption({
      series: [{
        label: labelOption
      },
        {
          label: labelOption
        }
      ]
    });
  }
};
const labelOption = {
  show: true,
  position: app.config.position,
  distance: app.config.distance,
  align: app.config.align,
  verticalAlign: app.config.verticalAlign,
  rotate: app.config.rotate,
  formatter: '{c}',
  fontSize: 16,
  rich: {
    name: {}
  }
};
option = {
  color: ['#31a7c2','#6fe987'],
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend: {
    textStyle:{color: '#ffffff'},
    data: ['A类考生', 'B类考生']
  },
  toolbox: {
    show: true,
    orient: 'vertical',
    left: 'right',
    top: 'center',
    feature: {
      mark: {
        show: true
      },
      dataView: {
        show: true,
        readOnly: false
      },
      magicType: {
        show: true,
        type: ['stack', 'bar', 'line']
      },
      restore: {
        show: true
      },
      saveAsImage: {
        show: true
      }
    }
  },
  xAxis: [{
    type: 'category',
    axisLabel : {
      textStyle: {
        color: '#ffffff',
      }
    },
    axisTick: {
      show: false
    },
    data: ['2018', '2019', '2020', '2021', '2022']
  }],
  yAxis: [{
    min: 240,
    max: 278,
    type: 'value',
    axisLabel : {
      textStyle: {
        color: '#ffffff',
      }
    }
  }],
  series: [{
    name: 'A类考生',
    type: 'line',
    barGap: 0,
    smooth: true,
    label: labelOption,
    emphasis: {
      focus: 'series'
    },
    data: [260, 270, 264, 263, 273]
  },
    {
      name: 'B类考生',
      type: 'line',
      smooth: true,
      label: labelOption,
      emphasis: {
        focus: 'series'
      },
      data: [250, 260, 254, 253, 263]
    }
  ]
}
export {
  option
}
